#pragma once

#include "Game/Process/RenderProcess.h"
#include "Render/Texture/Picture2DTexture.h"
#include "Render/Texture/RenderTarget.h"
#include "Render/Tradition/RHIRenderPass.h"
#include "Render/Tradition/GraphicsPipeline.h"
#include "Render/Texture/ColorRenderTarget.h"
#include "Render/Texture/CubemapTexture.h"
#include "Render/Texture/DepthRenderTarget.h"
#include "Render/Shader/RHIDescriptor.h"
#include "Render/Tradition/RHIFramebuffer.h"
#include "LocalEntity.h"


class DeferredProcess : public RenderProcess
{
	DECLARE_PROCESS(DeferredProcess)

	struct Light {
		glm::vec4 position;
		glm::vec4 target;
		glm::vec4 color;
		glm::mat4 viewMatrix;
	};

	struct Ubo {
		glm::vec4 viewPos;
		Light lights[3];
		int32 useShadows;
		int32 checkShadows;
	};

public:

	int32 mUseShadows;

	int32 mCheckShadows;

protected:

	virtual void OnInit() override;

	virtual void OnTick(float deltaTime) override;

	virtual void OnResize() override;

protected:

	std::vector<LocalEntity*> mLightEntitys;

	RefCountPtr<RHIBuffer> mUboBuffer;

	RefCountPtr<RHISampler> mCommonSampler;

	DescriptorMask mDescriptorMask;

	RefCountPtr<RHIDescriptor> mDescriptor;

	RefCountPtr<GraphicsPipeline> mPipeline;

	RefCountPtr<RHIRenderPass> mRenderPass;

	RefCountPtr<RHIFrameBuffer> mFrameBuffer;

	RefCountPtr<ColorRenderTarget> mColorRenderTarget;

	RefCountPtr<DepthRenderTarget> mDepthRenderTarget;

};
